package com.aliyun.messagemgt.controller;

import com.aliyun.messagemgt.application.service.MessageRecordService;
import com.aliyun.messagemgt.dto.query.MessageRecordQueryDTO;
import com.aliyun.messagemgt.dto.query.MyMsgQueryDTO;
import com.aliyun.messagemgt.web.controller.MessageRecordController;
import com.github.pagehelper.Page;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.junit.MockitoJUnitRunner;
import org.springframework.test.annotation.Rollback;

import java.util.ArrayList;

/**
 * @author wenyaxin
 * @date 2020/12/2
 */
@RunWith(MockitoJUnitRunner.class)
public class MessageRecordControllerTest {

    @InjectMocks
    private MessageRecordController messageRecordController;

    @Mock
    private MessageRecordService messageRecordService;

    @Test
    @Rollback()
    public void listTest(){
        Mockito.when(messageRecordService.selectMessageRecord(Mockito.any())).thenReturn(new Page<>());
        messageRecordController.list(new MessageRecordQueryDTO());
    }

    @Test
    @Rollback()
    public void messageListOwnerDeptTest(){
        Mockito.when(messageRecordService.messageListOwnerDept(Mockito.any())).thenReturn(new ArrayList<>());
        messageRecordController.messageListOwnerDept(new MessageRecordQueryDTO());
    }

    @Test
    @Rollback()
    public void messageListMyMsgsTest(){
        Mockito.when(messageRecordService.messageListMyMsgs(Mockito.any())).thenReturn(new Page<>());
        messageRecordController.messageListMyMsgs(new MyMsgQueryDTO());
    }
}
